import request from "@/utils/request";


const sessionStorage = window.sessionStorage;
export function getDictList(dictName) {
  return new Promise((resolve) => {
    let sessionLocalObj = sessionStorage.getItem(dictName)
    if (sessionLocalObj) {
      resolve(JSON.parse(sessionLocalObj))
      return
    }

    request({
      url: '/website/dict/data/type/' + dictName,
      method: 'get'
    }).then(res => {
      if (res.code == 200) {
        let dictListStr = JSON.stringify(res)
        sessionStorage.removeItem(dictName)
        sessionStorage.setItem(dictName, dictListStr)
      }
      resolve(res)
    })
  })

}

